<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="isperp" uri="/WEB-INF/tlds/isperp.tld"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<script type="text/javascript" charset="utf-8"
	src="js/libs/editor/ueditor.config.js"></script>
<script type="text/javascript" src="js/libs/editor/ueditor.js"></script>

<form:form commandName="model" cssClass="validate"
	action="knowledge/knowledgeItem/save">
	<form:hidden path="id" />
	<div class="header">
		<h2>
			&nbsp;&nbsp;知识信息<span><font color="red">（* 为必填项）</font> </span>
		</h2>
	</div>

	<table class="form-table">
		<tbody>
			<tr>
				<td class="td1">分类：</td>
				<td class="td2"><form:input path="kngKnowledgeCategoryId"
						cssClass="hidden" /> <isperp:treeSelector
						id="selectParentCategory"
						url="knowledge/knowledgeCategory/getTree"
						valueControlId="kngKnowledgeCategoryId"
						displayValue="${categoryName}" displayValueCssClass="required"></isperp:treeSelector>
				</td>
			</tr>

			<tr>
				<td class="td1">标题：</td>
				<td class="td2"><form:input path="title" cssClass="required"
						maxlength="200" cssStyle="width:80%" /></td>
			</tr>

			<tr>
				<td class="td1">关键字（以逗号分隔）：</td>
				<td class="td2"><form:input path="keyword" maxlength="200"
						cssStyle="width:80%" cssClass="required" />
				</td>
			</tr>
			<tr>
				<td class="td1">内容：</td>
				<td class="td2"><form:textarea path="contents"
						cssStyle="height:200px;width:90%" cssClass="editor required" />
				</td>
			</tr>
			<tr>
				<td class="td1">附件：
				<td class="td2"><isperp:uploader sourceId="${model.id }"
						id="knowledgeItemFiles"></isperp:uploader>
				</td>
			</tr>
			<tr>
				<td class="td1">权限：</td>
				<td class="td2"><form:radiobutton label="公司级"
						value="companyLevel" path="accessRight" /> <form:radiobutton
						label="公开" value="public" path="accessRight" /></td>
			</tr>

		</tbody>
	</table>
</form:form>
<div class="header">
	<h3>关联流程</h3>
</div>
<isperp:processRelation businessKey="${model.id }" readonly="false"
	processKey="knowledgeProcess" projectIdControl="projectId"></isperp:processRelation>

<isperp:buttonList>
	<c:choose>
		<c:when test="${empty model.processId }">
			<isperp:processButtons processKey="knowledgeProcess"
				processId="${model.processId }" businessKey="${model.id }"
				formId="knowledgeForm"></isperp:processButtons>
			</button>
		</c:when>
		<c:otherwise>

			<button class="submit" onclick="save()">
				<span class="icon icon-save"></span>保存
			</button>
		</c:otherwise>


	</c:choose>

	<c:if test="${showStep eq true }">
		<c:if test="${not empty pid }">
			<button class="grey"
				onclick="window.location.href= isperp.changeUrlParam( window.location.href,id,'${pid}');return false;">
				<span class="icon icon-chevron-left"></span>上一条
			</button>
		</c:if>
		<c:if test="${not empty nid }">
			<button class="grey"
				onclick="isperp.submitForm({success:function(){isperp.reloadParentControl(); window.location.href= isperp.changeUrlParam( window.location.href,id,'${nid}');}});return false;">
				<span class="icon icon-chevron-right"></span>保存并进入下一条
			</button>
		</c:if>
	</c:if>


</isperp:buttonList>

<script type="text/javascript">
	UE.getEditor('contents');
	function save() {
		isperp.submitForm({
			success : function(data) {
				if (data.data=="已提交审核")
				{
				   isperp.alert(data.data);
				   isperp.reloadParentControl();
				   isperp.closeDialog();
				   
				}else
				{
				   isperp.reloadParentControl();
				   isperp.closeDialog();
				}
					
			}
		});
		return false;
	}
</script>
